﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;
namespace map.member.order
{
    public partial class buy_9 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind1();
            }
        }
        private void bind1()
        {
            taobaotrade t = taobaotrade.Find(" buyer_nick = '"
                + AliApi.appUserId + "' and taobaostatus = '"+TRADE_STATUS.Buyer_Recieved +"' and cbtrantype!='"+TRADE_TranType .PostBySelf +"'");
            WebPager1.DataSource = t.MyTable;
            WebPager1.DataBind();
        }

        protected void WebPager1_PageIndexChanged(object sender, RuleCode.Controls.PageChangedEventArgs e)
        {
            WebPager1.CurrentPageIndex = e.NewPageIndex;
            bind1();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
            if (e.CommandName == "t2")
            {
                taobaotrade ui = taobaotrade.Find(" recid = " + id);
                ui.taobaostatus.Value = TRADE_STATUS .Seller_Refunding ;
                ui.Modify();
                MessageBox.Show(this.UpdatePanel1, "操作成功.");
                bind1();
            }

            if (e.CommandName == "cp")    //确认付款到卖家
            {

                Response.Redirect(ResolveUrl("~/member/order/Buy_Pay.aspx?type=1&id="+id));

                //taobaotrade ui = taobaotrade.Find(" recid = " + id);    
                //cbuser u2 = cbuser.Find(" cbuserid = '" + ui.seller_nick.ToString() + "'");
                //double need = zfunction.str2double(ui.taobaopayment.ToString());
                //cbmoneytrans mt = cbmoneytrans.Find("1=2");
                //mt.New();
                //mt.cbuserid.Value = ui.seller_nick .Value ;
                //mt.cbmoney.Value = -need;
                //mt.cbmoneytrantype.Value = MONEY_TransType.UnBlock ;
                //mt.jccreatedate.Value = DateTime.Now;
                //mt.jccreatetime.StringValue = DateTime.Now.ToLongTimeString();
                //mt.jcdesc.Value = ui.RECID.ToString() + " " + ui.taobaoname.ToString();
                //mt.NoYes_dongjie.Value = RuleCode.Enum.NoYes.No;
                //mt.RefTable.Value = "taobaotrade";
                //mt.RefRecID.Value = id;
                //mt.Insert();
                //u2.cbmoneyD.Value -= need;

                //cbmoneytrans mt2 = cbmoneytrans.Find("1=2");
                //mt2.New();
                //mt2.cbuserid.Value = ui.seller_nick.ToString();
                //mt2.cbmoney.Value = need;
                //mt2.cbmoneytrantype.Value = MONEY_TransType.SaleIn ;
                //mt2.jccreatedate.Value = DateTime.Now;
                //mt2.jccreatetime.StringValue = DateTime.Now.ToLongTimeString();
                //mt2.jcdesc.Value = ui.RECID.ToString() + " " + ui.taobaoname.ToString();
                //mt2.NoYes_dongjie.Value = RuleCode.Enum.NoYes.No;
                //mt.RefTable.Value = "taobaotrade";
                //mt.RefRecID.Value = id;
                //mt2.Insert();
                //u2.cbmoney.Value = u2.cbmoney.Value + need;
                //u2.cbmoneyZ.Value = u2.cbmoneyZ.Value + need;
                ////u2.cbmoneyD.Value = need;
                //u2.Modify();


                //ui.taobaostatus.Value = TRADE_STATUS.Trade_Finished;
                //ui.Modify();
                //MessageBox.Show(this.UpdatePanel1, "操作成功，交易金额:" + need.ToString()+"已转入卖家账户中！");
                //bind1();


            }
        }
    }
}
